home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / snpd1292.zip / SCRNSIZE.C < prev    next >
C/C++ Source or Header  |  1992-12-26  |  686b  |  41 lines

  1. /*
  2. **   Get screen size (by  Bob Jarvis)
  3. */
  4.  
  5. #include <dos.h>
  6.  
  7. #ifndef __TURBOC__
  8.  #define far _far
  9. #endif
  10.  
  11. #ifndef MK_FP
  12.  #define MK_FP(seg,offset) \
  13.         ((void far *)(((unsigned long)(seg)<<16) | (unsigned)(offset)))
  14. #endif
  15.  
  16. int get_screen_rows(void)
  17. {
  18.       char far *bios_crt_rows_ptr = MK_FP(0x0040, 0x0084);
  19.  
  20.       return(1 + *bios_crt_rows_ptr);
  21. }
  22.  
  23. int get_screen_cols(void)
  24. {
  25.       int far *bios_crt_cols_ptr = MK_FP(0x0040, 0x004A);
  26.  
  27.       return(*bios_crt_cols_ptr);
  28. }
  29.  
  30. #ifdef TEST
  31.  
  32. #include <stdio.h>
  33.  
  34. void main(void)
  35. {
  36.       printf("rows = %d  cols = %d\n",
  37.             get_screen_rows(), get_screen_cols());
  38. }
  39.  
  40. #endif
  41.